typedef unsigned long int word;

#define STACK_SIZE (1<<16)
#define GLOBALS_SIZE (1<<8)
#define HEAP_SIZE (1<<16)

extern word machine_ret_register;
extern word machine_env_register;

extern word machine_stack[STACK_SIZE];
extern word machine_globals[GLOBALS_SIZE];

extern word machine_heap_a[HEAP_SIZE];
extern word machine_heap_b[HEAP_SIZE];

extern word *machine_from_heap;
extern word *machine_to_heap;

#define FROM_HEAP(p) (machine_from_heap+p)
#define TO_HEAP(p) (machine_to_heap+p)
#define FROM_HEAP_REF(p) machine_from_heap[p]
#define TO_HEAP_REF(p) machine_to_heap[p]

#define TAG(w) ((w) & 0xFF)
#define VAL(w) ((w) >> 8)
#define OBJECT_TAG_VAL(t,v) ((v) << 8 | (t))
#define VAL_BITS 0xFFFFFFFFFFFFFF

enum tag {
  // atomic
  tag_bool = 0,
  tag_null = 1,
  tag_integer = 2,
  tag_symbol = 3,
  tag_character = 4,

  // data
  tag_string = 5,

  // complex
  tag_box = 6,
  tag_cons = 7,
  tag_vector = 8,
  tag_closure = 9,
  tag_record = 10,
};

extern char *tag_name[];

